package
{
	import mx.collections.ArrayCollection;
	
	public class WrongAnswersCollection extends ArrayCollection
	{
		public function WrongAnswersCollection(questions:ArrayCollection)
		{
			super();
			
			for (var i:Number=0; i <questions.length ; i++)
			{		
				addItem( {question:"Quesito" + i,value:0});
			}
		}
		
		public function incMistakes(questionIndex:Number):void
		{
			var mistakes:* =  getItemAt(questionIndex);
			mistakes.value++;
			setItemAt( mistakes,questionIndex);
		}
		
		public function get mistakes():Number
		{
			var mistakes:Number = 0;
			
			for each ( var obj:Object in this)
			{
				mistakes += obj.value;
			}
			
			return mistakes;
		}
		
		public function get questionsWithMistakes():Number
		{
			var questionsWithMistakes:Number = 0;
			
			for each ( var obj:Object in this)
			{
				if (obj.value>0) questionsWithMistakes +=1;
			}
			
			return questionsWithMistakes;
		}

		
		public function areThereMistakes():Boolean
		{
			return mistakes>0;
		}
		
	}
}